package com.hk.migration.cannal.process;

import com.alibaba.otter.canal.protocol.CanalEntry;
import com.hk.migration.cannal.CanalData;
import com.hk.migration.cannal.CanalProcess;
import com.hk.migration.cannal.DataHandler;
import com.hk.migration.db.hk.UserList;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户表数据
 */
@Slf4j
@Component
@AllArgsConstructor
public class UserListProcess implements CanalProcess {

    
    
    @Override
    public boolean apply(String tableName, CanalEntry.EventType eventType) {
        return "user_list".equals(tableName);
    }

    @Override
    public boolean processData(List<CanalData> beforeCanalDataList, List<CanalData> afterCanalDataList, CanalEntry.EventType eventType) {
        if (eventType == CanalEntry.EventType.INSERT){

        }
        UserList userListBefore = DataHandler.convertToBean(beforeCanalDataList, UserList.class);
        log.info("修改前数据userListBefore={}",userListBefore);
        UserList userListAfter = DataHandler.convertToBean(afterCanalDataList, UserList.class);
        log.info("修改后数据userListAfter={}",userListAfter);


        return false;
    }
}
